package org.jeecg.modules.land.entity;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;

@Setter
@Getter
public class IncomeSummary {
    public String companyName;
    public String code;
    public String companyLevel;
    public BigDecimal bookArea;
    public BigDecimal bookNetValue;
    public BigDecimal bookOriginalValue;
    public BigDecimal cardArea;
    public BigDecimal noCardArea;
    public List<TbAssetManagement> assetManagements; // 存储汇总所基于的原始数据
    public void addBookArea(BigDecimal bookArea) {
        if (this.bookArea == null) {
            this.bookArea = BigDecimal.ZERO;
        }
        if (bookArea != null) {
            this.bookArea = this.bookArea.add(bookArea);
        }
    }

    public void addBookNetValue(BigDecimal bookNetValue) {
        if (this.bookNetValue == null) {
            this.bookNetValue = BigDecimal.ZERO;
        }
        if (bookNetValue != null) {
            this.bookNetValue = this.bookNetValue.add(bookNetValue);
        }
    }

    public void addBookOriginalValue(BigDecimal bookOriginalValue) {
        if (this.bookOriginalValue == null) {
            this.bookOriginalValue = BigDecimal.ZERO;
        }
        if (bookOriginalValue != null) {
            this.bookOriginalValue = this.bookOriginalValue.add(bookOriginalValue);
        }
    }

    public void addCardArea(BigDecimal cardArea) {
        if (this.cardArea == null) {
            this.cardArea = BigDecimal.ZERO;
        }
        if (cardArea != null) {
            this.cardArea = this.cardArea.add(cardArea);
        }
    }

    public void addNoCardArea(BigDecimal noCardArea) {
        if (this.noCardArea == null) {
            this.noCardArea = BigDecimal.ZERO;
        }
        if (noCardArea != null) {
            this.noCardArea = this.noCardArea.add(noCardArea);
        }
    }
    public IncomeSummary(String companyName, String code, String companyLevel, BigDecimal bookArea, BigDecimal bookNetValue, BigDecimal bookOriginalValue, BigDecimal cardArea, BigDecimal sumNoCardArea, List<TbAssetManagement> assetManagements) {
        this.companyName = companyName;
        this.code = code;
        this.companyLevel = companyLevel;
        this.bookArea = bookArea;
        this.bookNetValue = bookNetValue;
        this.bookOriginalValue = bookOriginalValue;
        this.cardArea = cardArea;
        this.noCardArea = sumNoCardArea;
        this.assetManagements = assetManagements;
    }

    // 深拷贝方法
    public IncomeSummary deepCopy() {
//        List<TbAssetManagement> copiedAssets = new ArrayList<>();
//        if (this.assetManagements != null) {
//            for (TbAssetManagement asset : this.assetManagements) {
//                // 假设 TbAssetManagement 也有深拷贝方法
//                copiedAssets.add(new TbAssetManagement(
//                        asset.getCompanyName(),
//                        asset.getCode(),
//                        asset.getCompanyLevel(),
//                        asset.getBookArea(),
//                        asset.getBookNetValue(),
//                        asset.getBookOriginalValue(),
//                        asset.getCardArea(),
//                        asset.getNoCardArea()
//                ));
//            }
//        }
        return new IncomeSummary(
                this.companyName,
                this.code,
                this.companyLevel,
                this.bookArea,
                this.bookNetValue,
                this.bookOriginalValue,
                this.cardArea,
                this.noCardArea,
                this.assetManagements
        );
    }
}
